<template>
  <div>
    <div :style="{height: toolbarHei +'px'}"></div>
    <nut-navbar title="派单收款" left-text="返回" left-show @click-back="clickLeft"></nut-navbar>

    <div>开发中</div>
  </div>
</template>
<script>
// 零售
import tool from "@/utils/tool";
import {useGlobal} from "@/stores/useGlobal";
import advFilter from "./xsadvfilter.vue";
const global = useGlobal()
export default {
  components: {advFilter},
  name: 'pdsk',
  data () {
    return {
      active: 0,
      amount: '0.00',
      orders: 0,
      customers: 0,
      searchModel: {
        searchType: 'quick',
        currentPage: 1,
        pageSize: 30,
        keyWord: '',
        gpType: '商品汇总',
        beginDate: tool.getDay(),
        endDate: tool.getDay(),
      },
      showDetail: false,
      list: [],
      listDetail: []
    }
  },
  created () {
    this.getList()
  },
  computed: {
    title () {
      return `${this.searchModel.beginDate} - ${this.searchModel.endDate}`
    },
    hei () {
      return window.innerHeight - 260
    },
    toolbarHei () {
      return global.statusBarHeight
    }
  },
  methods: {
    clickLeft () {
      this.$router.go(-1)
    },
    // 弹出搜索
    openAdvFilter () {
      this.$refs.filterRef.open()
    },
    // 高级搜索
    doAdvSearch (model) {
      this.list = []
      this.searchModel.currentPage = 1
      this.searchModel.searchType = 'adv'
      this.searchModel = Object.assign(this.searchModel, model)
      this.getList()
    },
    // 快速搜索
    quickSearch () {
      this.list = []
      this.searchModel.beginDate = tool.getDay()
      this.searchModel.endDate = tool.getDay()
      this.searchModel.currentPage = 1
      this.searchModel.searchType = 'quick'
      this.getList()
    },
    // 选择汇总方式
    changeGp () {
      this.searchModel.currentPage = 1
      this.list = []
      this.getList()
    },
    more () {},
    action ({state}) {
      if(state.upRefresh) {
        this.searchModel.currentPage = this.searchModel.currentPage + 1
        this.getList(state)
      }
      if(state.dropRefresh) {
        this.searchModel.currentPage = 1
        this.getList(state)
      }
    },
    getList (state) {
      tool.post('app/getSaleGp', this.searchModel, true).then(ret => {
        if(ret.stat) {
          this.orders = ret.data.orders
          this.amount = ret.data.amount
          this.customers = ret.data.customers
          if(state) {
            if(state.upRefresh) {
              state.upRefresh = false
              if(ret.data.list.length === 0) state.finished = true
              ret.data.list.map(row => {
                this.list.push(row)
              })
            }
            if(ret.data.list.length === 0) state.finished = true
            if(state.dropRefresh) {
              state.dropRefresh = false
              this.list = []
              ret.data.list.map(row => {
                this.list.push(row)
              })
            }
          }
          else {
            this.list = []
            ret.data.list.map(row => {
              this.list.push(row)
            })
            this.loading = false
            this.total = ret.data.total
            if(this.list.length < this.pageSize) this.finished = true
          }
        }
      })
    },
    todetail (item) {
      let mod = Object.assign(this.searchModel,{name: item.name})
      this.listDetail = []
      tool.post('app/getSaleGpDetail', mod).then(ret => {
        this.listDetail = ret.data
        this.showDetail = true
      })
    },
  }
}

</script>

<style scoped lang="scss">
.detail {
  border-bottom: 1px solid rgba(0,0,0,0.1);
  margin-bottom: 5px;
  padding-bottom: 5px;
}
.item {
  background-color: white;
  padding: 10px;
  display: flex;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  &:active {
    background-color: rgba(0,0,0,0.06);
  }
  .name {
    font-size: 14px;
    color: #6b6d71;
  }
  .amount {
    font-size: 14px;
    color: #1e9fff;
  }
}
.draft {
  color: #0bc15f !important;
}
.accounted {
  color: #1e9fff !important;
}
.top {
  .title {
    font-weight: bold;
    font-size: 14px;
    color: #8a8f97;
  }
  .num {
    font-weight: bold;
    font-size: 15px;
    color: #1e9fff;
  }
}

</style>